


function Statistics() {
    this.createEl();
}




Statistics.prototype = {
    
    createEl : function() {
        
        var container = document.createElement("div"),
        leftDiv = document.createElement("div"),
        rightDiv = document.createElement("div"),
        me = this;
        
        me.el = container;
        container.className = "statistics clearFix";
        
        
        leftDiv.className = "left";
        leftDiv.innerHTML = "Competence<br /> Creativity<br /> Business sense";
        
        
        container.appendChild(leftDiv);
        
        rightDiv.className = "right clearfix";
        me.rightDiv = rightDiv;
        
        container.appendChild(rightDiv);
        me.setPercent(0, 1, 3);
        
    },
    
    setPercent : function(time, level) {
        var me = this,
        i,
        p,
        numberOfBars = 3;
        me.percent = [];
        
        for(i = 0; i < numberOfBars; i++) {
            p = Math.round((Math.random() * 0.1 + 0.3 + ((level - 2)/10)) * 100);
            if(p > 100) {
                p = 100;
            }
            me.percent[i] = p;
                
        }
        me.createBars(numberOfBars);
    },
    
    createBars : function(numberOfBars) {
        
        var me = this,
        i,
        barContainer,
        bar,
        percent;
        
        if(typeof me.bars === "undefined") {
            
            me.bars = [];
            
            for(i = 0; i < numberOfBars; i++) {

                barContainer = document.createElement("div");
                barContainer.className = "barContainer";                

                bar = document.createElement("div");
                bar.className = "bar";
                
                me.bars.push(bar);
                
                percent = me.percent[i];




                bar.style.width = percent + "%";
                bar.innerText = percent + "%";

                barContainer.appendChild(bar);

                me.rightDiv.appendChild(barContainer);

            }
        }else{
            for(i = 0; i < me.bars.length; i++) {


                percent = me.percent[i];
                bar = me.bars[i];

                bar.style.width = percent + "%";
                bar.innerText = percent + "%";

            }
        }
        
    },
    
    setZeroPercent : function() {
        
        var i,
        me = this,
        l = me.percent.length;
        
        for(i = 0; i < l; i++) {
            me.percent[i] = 0;
        }
        me.createBars(l);
        
    },
    
    
    getEl : function() {
        return this.el;
    }
    
};